<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript" src="jquery.min.js"></script>
	<script type="text/javascript">
  $(function() {
    console.log("用户5555555555555555555");
    $.ajax({url:"http://localhost:8080/ssm-v2/login/5",success:function(result){
      console.log(result);
      var ws = new WebSocket("ws://localhost:8080/ssm-v2/myHandler")
       ws.onopen = function () {
        console.log("onpen");
        //ws.send("{}");
       }
       ws.onclose = function () {
        console.log("onclose");
       }

       // 收到消息
       ws.onmessage = function(evnt) {
    	   var jsonObj = eval( '(' +evnt.data+ ')' );
           $("#msg").append("<p><font color='red'>用户名:" + jsonObj.用户名 + ",金额:" + jsonObj.金额 + "</font></p>");
           console.log(" 55555555555555 websocket.onmessage 555555555555555==  " +evnt.data );
       };
    }});
  })
</script>
  </head>
  
  <body>
			<!-- 消息展示框 -->
            <div id="msg" style="width: 100%; height: 70%; border: 1px solid yellow;overflow: auto;"></div>
  </body>
</html>
